package com.miku.blog.controller;

import com.miku.blog.annotation.SystemLog;
import com.miku.blog.domain.param.ReceptionParam;
import com.miku.blog.domain.pojo.ResponseResult;
import com.miku.blog.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author shkstart
 * @create ${}YEAR-05-31 16:34
 */
@Api(tags = "后台管理系统[评论]")
@RequestMapping("/admin")
@RestController
public class CommentController {


    @Autowired
    private CommentService commentService;

    @SystemLog(notes = "获取评论消息列表{后台管理系统}")
    @ApiOperation(value = "获取评论消息接口", notes = "分页查询未删除评论信息")
    @GetMapping("/comments")
    public ResponseResult comments(@RequestParam("current") Integer current, @RequestParam("size") Integer size,
                                   @RequestParam(value = "type",required = false) Integer type,
                                   @RequestParam(value = "isReview",required = false) Integer isReview,
                                   @RequestParam(value = "keywords", required = false) String keywords)
    {
        return commentService.comments(current, size, type,isReview, keywords);
    }

    @SystemLog(notes = "删除评论(物理)")
    @ApiOperation(value = "删除评论(物理)接口", notes = "删除评论 (真正删除)")
    @DeleteMapping("/comments")
    public ResponseResult deleteCommentList(@RequestBody Integer[] commentIdList) {
        return commentService.deleteCommentListById(commentIdList);
    }


    @SystemLog(notes = "更新评论审核状态{后台管理系统}")
    @ApiOperation(value = "更新评论审核状态接口", notes = "更新评论审核状态 { 根据评论ID 、 isReview 审核0/通过1 }")
    @PutMapping("/comments/review")
    public ResponseResult updateComment(@RequestBody ReceptionParam receptionParam){
        return commentService.updateComment(receptionParam);
    }

}
